"use strict"

/* seeds to setup init datas */
var bcrypt  = require('bcryptjs');
var async   = require('async');
var mongo   =  require ('mongodb');
var objectId = mongo.ObjectID;

seedUsers = [
  {
    firstName:  'Admin',
    lastName: 'Super',
    username: 'admin',
    password: 'admin123456',
    email:  'lei.he@aivics.com',
    mobile: '13764211365',
    _id: objectId('503cf4730e9f580200000002'),
    activated: true,
  }
];

var db;

var dbUrl = process.env.MONGOHQ_URL || 'mongodb://@127.0.0.1:27017/hackhall';
mongo.Db.connect(dbUrl, function(error, client){
  if (error) throw error;
  else {
    db=client;
    users     = new mongo.Collection(db, 'users');
    accounts  = new mongo.Collection(db, 'accounts');
    accounts.remove(function(){});
    users.remove(function(){});

    accounts.insert({ code:'smrules' }, function(){});

    users.insert(seedUsers, function(){});

    db.close();
  }
});
